package org.apache.commons.httpclient.protocol;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.apache.commons.httpclient.ConnectTimeoutException;

public final class ReflectionSocketFactory
{
  private static Constructor INETSOCKETADDRESS_CONSTRUCTOR;
  private static boolean REFLECTION_FAILED = false;
  private static Method SOCKETBIND_METHOD;
  private static Method SOCKETCONNECT_METHOD;
  private static Class SOCKETTIMEOUTEXCEPTION_CLASS;
  static Class class$java$net$InetAddress;
  static Class class$java$net$Socket;

  static
  {
    INETSOCKETADDRESS_CONSTRUCTOR = null;
    SOCKETCONNECT_METHOD = null;
    SOCKETBIND_METHOD = null;
    SOCKETTIMEOUTEXCEPTION_CLASS = null;
  }

  static Class class$(String paramString)
  {
    try
    {
      Class localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }

  public static Socket createSocket(String paramString1, String paramString2, int paramInt1, InetAddress paramInetAddress, int paramInt2, int paramInt3)
    throws IOException, UnknownHostException, ConnectTimeoutException
  {
    Object localObject1;
    if (REFLECTION_FAILED)
      localObject1 = null;
    while (true)
    {
      label9: return localObject1;
      try
      {
        Class localClass1 = Class.forName(paramString1);
        Object localObject2 = localClass1.getMethod("getDefault", new Class[0]).invoke(null, new Object[0]);
        Socket localSocket = (Socket)localClass1.getMethod("createSocket", new Class[0]).invoke(localObject2, new Object[0]);
        Class localClass5;
        if (INETSOCKETADDRESS_CONSTRUCTOR == null)
        {
          Class localClass4 = Class.forName("java.net.InetSocketAddress");
          Class[] arrayOfClass3 = new Class[2];
          if (class$java$net$InetAddress != null)
            break label385;
          localClass5 = class$("java.net.InetAddress");
          class$java$net$InetAddress = localClass5;
          label101: arrayOfClass3[0] = localClass5;
          arrayOfClass3[1] = Integer.TYPE;
          INETSOCKETADDRESS_CONSTRUCTOR = localClass4.getConstructor(arrayOfClass3);
        }
        Constructor localConstructor1 = INETSOCKETADDRESS_CONSTRUCTOR;
        Object[] arrayOfObject1 = new Object[2];
        arrayOfObject1[0] = InetAddress.getByName(paramString2);
        arrayOfObject1[1] = new Integer(paramInt1);
        Object localObject3 = localConstructor1.newInstance(arrayOfObject1);
        Constructor localConstructor2 = INETSOCKETADDRESS_CONSTRUCTOR;
        Object[] arrayOfObject2 = new Object[2];
        arrayOfObject2[0] = paramInetAddress;
        arrayOfObject2[1] = new Integer(paramInt2);
        Object localObject4 = localConstructor2.newInstance(arrayOfObject2);
        Class localClass3;
        if (SOCKETCONNECT_METHOD == null)
        {
          if (class$java$net$Socket != null)
            break label393;
          localClass3 = class$("java.net.Socket");
          class$java$net$Socket = localClass3;
        }
        while (true)
        {
          Class[] arrayOfClass2 = new Class[2];
          arrayOfClass2[0] = Class.forName("java.net.SocketAddress");
          arrayOfClass2[1] = Integer.TYPE;
          SOCKETCONNECT_METHOD = localClass3.getMethod("connect", arrayOfClass2);
          if (SOCKETBIND_METHOD == null)
          {
            if (class$java$net$Socket != null)
              break;
            localClass2 = class$("java.net.Socket");
            class$java$net$Socket = localClass2;
            Class[] arrayOfClass1 = new Class[1];
            arrayOfClass1[0] = Class.forName("java.net.SocketAddress");
            SOCKETBIND_METHOD = localClass2.getMethod("bind", arrayOfClass1);
          }
          Method localMethod1 = SOCKETBIND_METHOD;
          Object[] arrayOfObject3 = new Object[1];
          arrayOfObject3[0] = localObject4;
          localMethod1.invoke(localSocket, arrayOfObject3);
          Method localMethod2 = SOCKETCONNECT_METHOD;
          Object[] arrayOfObject4 = new Object[2];
          arrayOfObject4[0] = localObject3;
          arrayOfObject4[1] = new Integer(paramInt3);
          localMethod2.invoke(localSocket, arrayOfObject4);
          localObject1 = localSocket;
          break label9:
          label385: localClass5 = class$java$net$InetAddress;
          break label101:
          label393: localClass3 = class$java$net$Socket;
        }
        label490: Class localClass2 = class$java$net$Socket;
      }
      catch (InvocationTargetException localInvocationTargetException)
      {
        Throwable localThrowable = localInvocationTargetException.getTargetException();
        if (SOCKETTIMEOUTEXCEPTION_CLASS == null);
        try
        {
          SOCKETTIMEOUTEXCEPTION_CLASS = Class.forName("java.net.SocketTimeoutException");
          if (!(SOCKETTIMEOUTEXCEPTION_CLASS.isInstance(localThrowable)))
            break label490;
          throw new ConnectTimeoutException("The host did not accept the connection within timeout of " + paramInt3 + " ms", localThrowable);
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          REFLECTION_FAILED = true;
          localObject1 = null;
        }
        break label9:
        if (localThrowable instanceof IOException)
          throw ((IOException)localThrowable);
        localObject1 = null;
        break label9:
      }
      catch (Exception localException)
      {
        REFLECTION_FAILED = true;
        localObject1 = null;
        break label9:
      }
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.protocol.ReflectionSocketFactory
 * JD-Core Version:    0.5.3
 */